/***************************************************************************
 *   Copyleft 2006-2007 by												   *
 *	 Iwanicki Krzysztof													   *
 *   <gamma.mini.pw.edu.pl/~iwanickik>									   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 ***************************************************************************/
#ifndef __XMLSERIALIZER_H__
#define __XMLSERIALIZER_H__

#include "../../Types/Types.h"
#include "./TinyXML/tinyxml.h"
#include "./Serializable.h"
#include "../Scene/Scene3D.h"
#include "../Objects/Surfaces/BSplineSurface.h"
#include "../Objects/Surfaces/BezierSurface.h"


class XMLSerializer {
private:
	cInt mIteratorPos;
	ObjectsListIt mIterator;


	Matrix4D LoadMatrix4D(TiXmlElement* pElem);
	Point4D LoadPoint3D(TiXmlElement* pElem);
	BSplineSurface* LoadBSplineSurface(TiXmlElement* pElem);
	BezierSurface* LoadBezierSurface(TiXmlElement* pElem);

protected:
	ObjectsList mLoadedObjects;
	Matrix4D mWorldMatrix;
public:

    /**************************************************************
    * Constructors                                                *
    ***************************************************************/
	XMLSerializer(): mIterator(cNull) { }
	virtual ~XMLSerializer() { }
    /**************************************************************
    * Operators                                                   *
    ***************************************************************/


    /**************************************************************
    * Other helpful functions                                     *
    ***************************************************************/
	cBool SaveFile(const cChar* fileName, Scene3D* scene);
	cBool LoadFile(const cChar* fileName);

	cVoid IterateObjects();
	Object3D* NextObject3D();
	Matrix4D GetWorldMatrix();
};                                                                 

#endif // __XMLSERIALIZER_H__